from django.conf.urls import url
from django.contrib import admin
from rest_framework_jwt.views import obtain_jwt_token


from .views import increments, user, skus, spus, specs, options, orders, permission, group, admin
from rest_framework.routers import DefaultRouter

urlpatterns = [
    # 由JWT完成登陆
    url(r'^authorizations/$', obtain_jwt_token),
    # 首页模块
    url(r'^statistical/total_count/$', increments.IncrementTotalCountView.as_view()),
    url(r'^statistical/day_increment/$', increments.IncrementDayCountView.as_view()),
    url(r'^statistical/day_active/$', increments.IncrementDayActiveView.as_view()),
    url(r'^statistical/day_orders/$', increments.IncrementDayOrdersView.as_view()),
    url(r'^statistical/month_increment/$', increments.IncrementMonthCountView.as_view()),
    url(r'^statistical/goods_day_views/$', increments.GoodsDayView.as_view()),
    # 用户模块
    url(r'^users/$', user.UserView.as_view()),
    # 新增商品的路由
    url(r'^skus/categories/$', skus.SKUViewSet.as_view({'get': 'categorie'})),
    # 获取spu数据
    url(r'^goods/simple/$', skus.SKUViewSet.as_view({'get': 'goodssimple'})),
    # 获取spu规格数据
    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SKUViewSet.as_view({'get': 'spuspecification'})),
    url(r'^goods/brands/simple/$', spus.SPUViewSet.as_view({'get': 'brand'})),
    url(r'^goods/channel/categories/$', spus.SPUViewSet.as_view({'get': 'channel'})),
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', spus.SPUViewSet.as_view({'get': 'channel2'})),
    # 规格选项
    url(r'^goods/specs/simple/$', options.OptionsViewSet.as_view({'get': 'simple'})),
    # 用户订单表
    # url(r'^orders/$',orders.OrdersView.as_view()),
    # url(r'^orders/(?P<pk>\d+)/$', orders.OrderView.as_view()),
    # 权限表路由
    url(r'^permission/content_types/$', permission.PermissionViewSet.as_view({'get': 'contenttype'})),

    # 分组表路由
    url(r'^permission/simple/$', group.GroupViewSet.as_view({'get': 'simple'})),
    # admin 自定义路由
    url(r'^permission/groups/simple/$', admin.UserViewSet.as_view({'get': 'simple'})),

]

# SKU表的路由
router = DefaultRouter()
router.register('skus', skus.SKUViewSet, base_name='skus')
urlpatterns += router.urls

# SKUSpecification表路由
router = DefaultRouter()
router.register('goods/specs', specs.SPUSpecificationViewSet, base_name='specs')
urlpatterns += router.urls


# SPU表路由
router = DefaultRouter()
router.register('goods', spus.SPUViewSet, base_name='spus')
urlpatterns += router.urls


# SpecificationOption表路由
router = DefaultRouter()
router.register('specs/options', options.OptionsViewSet, base_name='options')
urlpatterns += router.urls


# 用户订单表
router = DefaultRouter()
router.register('orders', orders.OrderViewSet, base_name='orders')
urlpatterns += router.urls


# 权限表
router = DefaultRouter()
router.register('permission/perms', permission.PermissionViewSet, base_name='perms')
urlpatterns += router.urls

# 分组表
router = DefaultRouter()
router.register('permission/groups', group.GroupViewSet, base_name='groups')
urlpatterns += router.urls

# 管理员表
router = DefaultRouter()
router.register('permission/admins', admin.UserViewSet, base_name='admins')
urlpatterns += router.urls

